﻿Imports _1065144_1065164.DataProvider
Imports System.Data.SqlClient
Public Class KhachHangThueNhaDAO
    Public Shared Function GetAll() As DataTable
        Dim listKhachHangThueNha As New DataTable()
        Dim cn As SqlConnection = New SqlConnection(_strConnectionString)
        Dim cmd As New SqlCommand()
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "ketKhachHangThueNhavaThongTinNhaThue"
        cmd.Connection = cn
        Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)
        da.Fill(listKhachHangThueNha)


        Return listKhachHangThueNha
    End Function


    Public Shared Sub Insert(ByVal sqlparameters As SqlParameter())
        Dim cn As SqlConnection = New SqlConnection(_strConnectionString)
        Dim cmd As New SqlCommand()
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "themkhthuenha"
        cmd.Parameters.AddRange(sqlparameters)

        cmd.Connection = cn
        cn.Open()
        cmd.ExecuteNonQuery()
        cn.Close()
    End Sub
    Public Shared Sub Update(ByVal sqlparameters As SqlParameter())
        Dim cn As SqlConnection = New SqlConnection(_strConnectionString)
        Dim cmd As New SqlCommand()
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "SuaKhachHangThueNha"
        cmd.Connection = cn
        cmd.Parameters.AddRange(sqlparameters)
        cn.Open()
        cmd.ExecuteNonQuery()
        cn.Close()
    End Sub
    Public Shared Sub Delete(ByVal sqlparameters As SqlParameter)
        Dim cn As SqlConnection = New SqlConnection(_strConnectionString)
        Dim cmd As New SqlCommand()
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "usp_XoaKhachThueNha"
        cmd.Connection = cn
        cmd.Parameters.Add(sqlparameters)
        cn.Open()
        cmd.ExecuteNonQuery()
        cn.Close()
    End Sub
End Class
